package com.cda.mall.controller;


import com.cda.mall.service.ICategoryService;
import com.cda.mall.service.IIndexImgService;
import com.cda.mall.service.IProductService;
import com.cda.mall.service.impl.IndexImgServiceImpl;
import com.cda.mall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 轮播图  前端控制器
 * </p>
 *
 * @author cda
 * @since 2021-11-13
 */
@RestController
@RequestMapping("/index")
@CrossOrigin
@Api(value = "提供首页数据显示所需的接口",tags = "首页管理")
public class IndexImgController {

    @Autowired
    private IIndexImgService indexImgService;
    @Autowired
    IProductService productService;
    @Autowired
    private ICategoryService categoryService;

    @GetMapping("/indeximg")
    @ApiOperation("首页轮播图接口")
    public ResultVO listIndexImgs(){
        return indexImgService.listIndexImgs();
    }

    @GetMapping("/list-recommends")
    @ApiOperation("新品推荐接口")
    public ResultVO listRecommendProducts(){
        ResultVO resultVO = productService.listRecommendProducts();
        return resultVO;
    }

    @GetMapping("/category-recommends")
    @ApiOperation("分类推荐商品接口")
    public ResultVO listRecommendProductsByCategory(){
        return categoryService.listFirstLevelCategories();
    }

}

